﻿<!-- #include file="../Include/Admin_Onlogin.asp" -->
<!-- #Include File="../../Include/Md5.asp" -->
<%
Dim sqlAuth, rsAuth, PurviewID
sqlAuth = "Select AuthID From Admin_Auth Where href='Admin/UpdatePwd' Order By sort Asc,AuthID Asc"
Call Exec(rsAuth,sqlAuth,2)
If rsAuth.BOF And rsAuth.EOF Then
	PurviewID = 0
Else
	PurviewID = rsAuth(0)
	CheckPurview PurviewID,0
End If
rsAuth.Close
Set rsAuth = Nothing
'执行的操作
Select Case Action
Case "SaveModify"
    Call SaveModify()
Case Else
    Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>修改管理员密码</title>" & vbCrLf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrLf
	Response.Write "<body>" & vbCrLf
    Response.Write "<form class='layui-form layui-form-pane' id=""myform"" name=""myform"" method='post' action='Admin_ModifyPwd.asp'>"
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>修改管理员密码</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">管理员名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-t"">" & vbCrlf
	Response.Write "            " & UserName & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">所属角色：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-t"">" & vbCrlf
	If AdminGroupID <> 0 Then
		sqlGetGroup = "select * from Admin_Group where GroupID=" & AdminGroupID & " and status=1"
		Call Exe_Conn(rsGetGroup,sqlGetGroup,1)
		If rsGetGroup.BOF And rsGetGroup.EOF Then
			rsGetGroup.Close
			Set rsGetGroup = Nothing
		Else
			Response.Write "            " & rsGetGroup("GroupName")
		End If
	Else
		Response.Write "            超级管理员"
	End If
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">新 密 码：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type='password' id='Password' name='Password' value="""" onmouseover=""layer.tips('初始密码：" & Decryptstr(Password) & "',this,{tips: [1, '#000']});"" onkeyup='javascript:EvalPwdStrength(document.forms[0],this.value);' onmouseout='layer.closeAll();javascript:EvalPwdStrength(document.forms[0],this.value);' onblur='javascript:EvalPwdStrength(document.forms[0],this.value);' lay-verify=""Password"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">密码强度：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            " & ShowPwdStrength & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">确认密码：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input type='password' id='PwdConfirm' name='PwdConfirm' value="""" onmouseover=""layer.tips('初始密码：" & Decryptstr(Password) & "',this,{tips: [1, '#000']});"" onmouseout=""layer.closeAll();"" lay-verify=""PwdConfirm"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <input name=""Action"" type=""hidden"" id=""Action"" value=""SaveModify"">" & vbCrlf
	Response.Write "            <button type=""button"" class=""layui-btn"" accesskey=""s"" lay-submit="""" lay-filter=""submit"">保存[S]</button>" & vbCrlf
	Response.Write "            <button type=""reset"" class=""layui-btn layui-btn-danger"" accesskey=""r"">重置[R]</button>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
    Response.Write "</form>" & vbCrLf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form','element'], function () {" & vbCrlf
	Response.Write "    var form = layui.form,element = layui.element;" & vbCrlf
	Response.Write "    //自定义表单验证" & vbCrlf
	Response.Write "    form.verify({" & vbCrlf
	Response.Write "        Password: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""请输入您的密码！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "        PwdConfirm: function (value, item) {" & vbCrlf
	Response.Write "            if ($('input[name=Password]').val() !== value){" & vbCrlf
	Response.Write "                item.select();" & vbCrlf
	Response.Write "                return ""新密码与确认密码不同！"";" & vbCrlf
 	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "    });" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveModify'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim rs, sql
		Dim Password, PwdConfirm
		
		Password = Trim(Request("Password"))
		PwdConfirm = Trim(Request("PwdConfirm"))
		If Password = "" Then
			Response.Write "{""code"":0,""msg"":""\u65b0\u5bc6\u7801\u4E0D\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If PwdConfirm <> Password Then
			Response.Write "{""code"":0,""msg"":""\u786e\u8ba4\u5bc6\u7801\u5fc5\u987b\u4e0e\u65b0\u5bc6\u7801\u76f8\u540c\uff01""}" & vbCrLf
			Response.End()
		End If
		If CheckBadChar(Password) = False Then
			Response.Write "{""code"":0,""msg"":""\u65b0\u5bc6\u7801\u4e2d\u542b\u6709\u975e\u6cd5\u5b57\u7b26\uff01""}" & vbCrLf
			Response.End()
		End If
		If FoundErr = True Then Exit Sub

		sql = "Select * from Admin where UserName='" & UserName & "'"
		Call Exe_Conn(rs,sql,3)
		If rs.BOF And rs.EOF Then
			Response.Write "{""code"":0,""msg"":""\u4e0d\u5b58\u5728\u6b64\u7ba1\u7406\u5458\uff01""}" & vbCrLf
			Response.End()
			rs.Close
			Set rs = Nothing
			Exit Sub
		End If
		rs("Password") = Encryptstr(Password)
		rs.Update
		rs.Close
		Set rs = Nothing
		Response.Write "{""code"":1,""msg"":""\u4fee\u6539\u5bc6\u7801\u6210\u529f\uff01\u4e0b\u6b21\u767b\u5f55\u65f6\u8bb0\u5f97\u6362\u7528\u65b0\u5bc6\u7801\u54e6\uff01"",""url"":""?""}" & vbCrLf
		Response.End()
	End If
End Sub

Function ShowPwdStrength()
    Dim strStrength
    strStrength = strStrength & "<script type='text/javascript' src='PwdStrength.js'></script>" & vbCrLf
    strStrength = strStrength & "<script type='text/javascript'>" & vbCrLf
    strStrength = strStrength & "<!--" & vbCrLf
    strStrength = strStrength & "window.onerror = ignoreError;" & vbCrLf
    strStrength = strStrength & "function ignoreError(){return true;}" & vbCrLf
    strStrength = strStrength & "function EvalPwdStrength(oF,sP){" & vbCrLf
    strStrength = strStrength & "  PadPasswd(oF,sP.length*2);" & vbCrLf
    strStrength = strStrength & "  if(ClientSideStrongPassword(sP,gSimilarityMap,gDictionary)){DispPwdStrength(3,'cssStrong');}" & vbCrLf
    strStrength = strStrength & "  else if(ClientSideMediumPassword(sP,gSimilarityMap,gDictionary)){DispPwdStrength(2,'cssMedium');}" & vbCrLf
    strStrength = strStrength & "  else if(ClientSideWeakPassword(sP,gSimilarityMap,gDictionary)){DispPwdStrength(1,'cssWeak');}" & vbCrLf
    strStrength = strStrength & "  else{DispPwdStrength(0,'cssPWD');}" & vbCrLf
    strStrength = strStrength & "}" & vbCrLf
    strStrength = strStrength & "function PadPasswd(oF,lPwd){" & vbCrLf
    strStrength = strStrength & "  if(typeof oF.PwdPad=='object'){var sPad='IfYouAreReadingThisYouHaveTooMuchFreeTime';var lPad=sPad.length-lPwd;oF.PwdPad.value=sPad.substr(0,(lPad<0)?0:lPad);}" & vbCrLf
    strStrength = strStrength & "}" & vbCrLf
    strStrength = strStrength & "function DispPwdStrength(iN,sHL){" & vbCrLf
    strStrength = strStrength & "  if(iN>3){ iN=3;}for(var i=0;i<4;i++){ var sHCR='cssPWD';if(i<=iN){ sHCR=sHL;}if(i>0){ GEId('idSM'+i).className=sHCR;}GEId('idSMT'+i).style.display=((i==iN)?'inline':'none');}" & vbCrLf
    strStrength = strStrength & "}" & vbCrLf
    strStrength = strStrength & "function GEId(sID){return document.getElementById(sID);}" & vbCrLf
    strStrength = strStrength & "//-->" & vbCrLf
    strStrength = strStrength & "</script>" & vbCrLf
    strStrength = strStrength & "<style>" & vbCrLf
    strStrength = strStrength & ".cssPWD{background-color:#EBEBEB;border-right:solid 1px #BEBEBE;border-bottom:solid 1px #BEBEBE;}" & vbCrLf
    strStrength = strStrength & ".cssWeak{background-color:#FF4545;border-right:solid 1px #BB2B2B;border-bottom:solid 1px #BB2B2B;}" & vbCrLf
    strStrength = strStrength & ".cssMedium{background-color:#FFD35E;border-right:solid 1px #E9AE10;border-bottom:solid 1px #E9AE10;}" & vbCrLf
    strStrength = strStrength & ".cssStrong{background-color:#3ABB1C;border-right:solid 1px #267A12;border-bottom:solid 1px #267A12;}" & vbCrLf
    strStrength = strStrength & ".cssPWT{width:132px;}" & vbCrLf
    strStrength = strStrength & "</style>" & vbCrLf
    strStrength = strStrength & "<table cellpadding='0' cellspacing='0' class='cssPWT' style='height:38px'><tr><td id='idSM1' width='33%' class='cssPWD' align='center'><span style='font-size:1px'>&nbsp;</span><span id='idSMT1' style='display:none;'>弱</span></td><td id='idSM2' width='34%' class='cssPWD' align='center' style='border-left:solid 1px #fff'><span style='font-size:1px'>&nbsp;</span><span id='idSMT0' style='display:inline;font-weight:normal;color:#666'>无</span><span id='idSMT2' style='display:none;'>中</span></td><td id='idSM3' width='33%' class='cssPWD' align='center' style='border-left:solid 1px #fff'><span style='font-size:1px'>&nbsp;</span><span id='idSMT3' style='display:none;'>强</span></td></tr></table>"
    ShowPwdStrength = strStrength
End Function
%>
